package wangwenjun.phase2.concurrencypattern.eventbus.google.demo07;

import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;

/**
 * @author ChangLiang
 * @date 2020/6/19
 */
@Slf4j
public class OrderQueryAcceptor {

    private final EventBus eventBus;

    public OrderQueryAcceptor(EventBus eventBus) {
        this.eventBus = eventBus;
        this.eventBus.register(this);
    }

    public void queryOrder(String orderNo) {
        log.info("{} do query the orderNo:{}", this.getClass().getSimpleName(), orderNo);
        this.eventBus.post(new OrderQueryRequest(orderNo));
    }

    @Subscribe
    public void handleOrderQueryResponse(OrderQueryResponse response) {
        log.info("{} handle query order response:{}",this.getClass().getSimpleName(), response);
    }
}
